﻿@using tour.szhome.common;
@{
    ViewBag.Title = "景区相册";
}
<h3>景区相册</h3>
<div style="padding-left:50px;">
        <hr />
        <table class="tb">
            <tr>
                <td colspan="2" bgcolor="#FFFFFF">
                    <a href="/manage/landscape">景区管理&gt;&gt; </a>
                    <span id="lblXMMC" style="color:Red;">@ViewBag.Name </span>图片上传的说明: 
                    <span style="color: Gray;">只允许上传的JPG,GIF格式图片, 每个文件大小不可超过1Mb.</span>              
                    <br>
                </td>
            </tr>
        </table>
        <hr />
        <table class="tb" style="padding:5px;width:99%;">
            <tbody>
                <tr>
                    <td align="center"><span>景区图：</span></td>
                    <td>
                        <input type="file" name="upload" id="upload" />
                        <br>
                        <ul style="list-style:none;float:left">
                            @foreach (var item in ViewBag.List)
                            {
                                <li id="@item.XCID" style="float:left;margin:5px;">
                                    <img name="Img" src="/uploadfiles/thumb/@item.TPLJ" style="height:100px;width:100px;border-width:0px;" />
                                    <a href="javascript:del_landscape(@item.XCID)">删除</a>
                                </li>
                            }
                        </ul>
                    </td>
                </tr>
            </tbody>
        </table>
    <hr />
</div>
@CommPath.StyleImport("public/plug-in/uploadify/uploadify.css")
@CommPath.ScriptImport("public/plug-in/uploadify/jquery.uploadify-3.2.js")
<script type="text/javascript">
    $(function(){
        //上传图片欲操作
        $('#upload').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData' : {'f':"@ViewBag.Folder"},
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                edit(data);
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });
    });


    function edit(img) {
        $.ajax({
            type: "post",
            url: "/manage/landscapeimg/json_edit",
            data: {
                XCID: 0,
                JQID: @ViewBag.ID,
                TPLJ: img,
                JQMC: "@ViewBag.Name"
                },
            dataType: "json",
            timeout: 30000, //over time：30s
            beforeSend: function () {
                window.top.qibu.msgbox.loading("正在提交申请，请稍后... ...");
            },
            success: function (data) {
                window.top.qibu.msgbox.hide();
                if (data) {
                    dlg.Msg.Inf("操作成功");
                    setTimeout("window.location.href=window.location.href", 1000);
                }
                else {
                    dlg.Msg.Err("操作失败");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                window.top.qibu.msgbox.hide();
                dlg.Msg.Err(errorThrown);
            }
        });
    }

    //delete
    function del_landscape(xid) {
        dlg.Confirm('提示', '确定要删除该项吗 ?', function () {
            $.getJSON("/landscapeimg/json_delete", { xid: xid }, function (data) {
                if (data) {
                    dlg.Msg.Cor("操作成功");
                    setTimeout("$('#' + " + xid + ").remove();", 500);
                }
                else {
                    dlg.Msg.Err("操作失败");
                }
            });
        });
    }
</script>